import { userAccountLogin } from '@/api/user'
// 用户模块
const user = {
  namespaced: true,
  // 存数据
  state: () => ({
    profile: {
      id: '',
      nickname: '',
      avatar: '',
      token: '',
      mobile: ''
    }
  }),
  // 该数据
  mutations: {
    setStateUser (state, payload) {
      state.profile = payload
    },
    // 清空用户数据
    clearUserInfo (state) {
      state.profile = {}
    }
  },
  // 异步
  actions: {
    async setUser (ctx, { account, password }) {
      const res = await userAccountLogin({ account, password })
      console.log(res)
      ctx.commit('setStateUser', res.result)
    }
  },
  // 计算属性
  getters: {}
}

export default user
